package chpt07;

import java.util.Scanner;

public class TestInteger {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int[] numbers = new int[3];
		for(int i = 0;i < numbers.length;i++){
			try{
				String line = scanner.nextLine();
				numbers[i] = Integer.parseInt(line);
			}catch(NumberFormatException nfe){
				System.out.println("输入整型格式不正确，请重新输入。");
				i--;continue;
			}
		}
	}
	
	public static int get(int[] array, int n) {
		if(array == null || n < 0 || n >= array.length)
			throw new IllegalArgumentException("无效参数。");
		return array[n];
	}
	
}
